#第一问，用类封装一个MyMath类
class MyMath:
    def add(self, a, b):
        return a + b

    def sub(self, a, b):
        return a - b

    def mul(self, a, b):
        return a * b

    def div(self, a, b):
        return a / b

    def ediv(self, a, b):
        return a // b

    def rem(self, a, b):
        return a % b

    def sqrt(self, a, b):
        return float(a ** (1 / 2))
a = MyMath()
a. add(10, 5)
print(a)

# 定义类
#第一个
class Cat:
    def __init__(self, a, b):
        self. name = a
        self. age = b

    def __str__(self):
        return "名字是:%s , 年龄是:%d" % (self. name, self. age)

    def eat(self):
        print(f"{self. name}在吃鱼")

    def drink(self):
        print(f"{self. name}在喝牛奶")

tom = Cat("汤姆", 30)
a = Cat("David", 20)
a. eat()

#第二个
class MyClass:
    countnum = 0
    def __init__(self, name, age):
        self. name = name
        self. age = age
        MyClass. countnum += 1

    def totalnum(self):
        print("总人数为:", MyClass. countnum)

    def displaystudent(self):
        print("名字：", self. name, " ", "年龄：", self. age)


#第三问，创建相应子类
class firstchild(MyClass):
    def great(self):
        print(f"{self. name}是大神")

class secondchild(MyClass):
    def good(self):
        print(f"我们都得向{self. name}看齐！")

A = firstchild("小天", 20)
B = secondchild("小天", 20)
A. great()
B. good()
print(A)
print(B)
